//
//  LoopView_CollectionViewCell.m
//  International_Hospital
//
//  Created by LiYiLin on 16/7/5.
//  Copyright © 2016年 LiYiLin. All rights reserved.
//

#import "LoopView_CollectionViewCell.h"
#import "LoopView_Model.h"
#import <UIImageView+WebCache.h>

@implementation LoopView_CollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    
    if (self = [super initWithFrame:frame]) {

        UIImageView * imageView = [[UIImageView alloc] init];
        [self addSubview:imageView];
        
        [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.mas_top).offset(0);
            make.left.mas_equalTo(self.mas_left).offset(0);
            make.bottom.mas_equalTo(self.mas_bottom).offset(0);
            make.right.mas_equalTo(self.mas_right).offset(0);
        }];
        self.imageView = imageView;
        
        UIPageControl * pageControl = [[UIPageControl alloc] init];
        [self addSubview:pageControl];
        
        pageControl.numberOfPages = 4;
        pageControl.pageIndicatorTintColor = [UIColor grayColor];
        pageControl.currentPageIndicatorTintColor = [UIColor whiteColor];
        
        [pageControl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(imageView.mas_bottom).offset(-5);
//            make.centerX.mas_equalTo(imageView.center.x);
            make.left.right.offset(0);
            make.height.offset(10);
        }];
        self.pageControll = pageControl;
    }
    return self;
}

- (void)setModel:(LoopView_Model *)model {
    
    _model = model;
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:model.imgsrc]];
    self.pageControll.currentPage = self.tag;

}

@end
